package com.itheima.service.impl;

import com.itheima.dao.ActRuSuspendedJobDao;
import com.itheima.pojo.ActRuSuspendedJob;
import com.itheima.service.ActRuSuspendedJobService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (ActRuSuspendedJob)表服务实现类
 *
 * @author makejava
 * @since 2022-01-16 15:48:51
 */
@Service("actRuSuspendedJobService")
public class ActRuSuspendedJobServiceImpl implements ActRuSuspendedJobService {
    @Resource
    private ActRuSuspendedJobDao actRuSuspendedJobDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id_ 主键
     * @return 实例对象
     */
    @Override
    public ActRuSuspendedJob queryById(String id_) {
        return this.actRuSuspendedJobDao.queryById(id_);
    }

    /**
     * 分页查询
     *
     * @param actRuSuspendedJob 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<ActRuSuspendedJob> queryByPage(ActRuSuspendedJob actRuSuspendedJob, PageRequest pageRequest) {
        long total = this.actRuSuspendedJobDao.count(actRuSuspendedJob);
        return new PageImpl<>(this.actRuSuspendedJobDao.queryAllByLimit(actRuSuspendedJob, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param actRuSuspendedJob 实例对象
     * @return 实例对象
     */
    @Override
    public ActRuSuspendedJob insert(ActRuSuspendedJob actRuSuspendedJob) {
        this.actRuSuspendedJobDao.insert(actRuSuspendedJob);
        return actRuSuspendedJob;
    }

    /**
     * 修改数据
     *
     * @param actRuSuspendedJob 实例对象
     * @return 实例对象
     */
    @Override
    public ActRuSuspendedJob update(ActRuSuspendedJob actRuSuspendedJob) {
        this.actRuSuspendedJobDao.update(actRuSuspendedJob);
        return this.queryById(actRuSuspendedJob.getId_());
    }

    /**
     * 通过主键删除数据
     *
     * @param id_ 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id_) {
        return this.actRuSuspendedJobDao.deleteById(id_) > 0;
    }
}
